<%--
    Document   : create fragment for notification tempalte
    Created on : 4/29/2014
    Author     : Anton Strack
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<div class="csd_content_form">
    <form method="POST" action="${config.getPath()}">
        <div class="form-group">
            <label class="form-control" for="name">Name:</label>
            <input class="form-control" id="name" name="name" autofocus="" required="" type="text"><br />
            <label class="form-control" for="message">Message:</label>
            <p>Write any message that recipients of the notification should see besides what event occurred.</p>
            <textarea class="form-control" id="message" name="message" required="" rows="5"></textarea><br />
            <label class="form-control" for="recipient">Notification Recipient:</label>
            <p>Select who the notification is for. Multiple recipients can be selected by holding down the control key while selecting the names.</p>
            <select class="form-control" id="recipient" name="recipient" multiple="1">
                <c:forEach items="${recipients}" var="recipient" >
                    <c:choose>
                        <%-- an admin can see all recipients --%>
                        <c:when test="${user.roleId == 2}">
                            <option value="${recipient.id}">${recipient.name}</option>
                        </c:when>
                        <c:when test="${user.roleId == recipient.roleId}">
                            <option value="${recipient.id}">${recipient.name}</option>
                        </c:when>
                    </c:choose>
                </c:forEach>
            </select><br />
            <label class="form-control" for="action">Trigger Action:</label>
            <p>Select the action that when preformed on the subject resource will trigger the notification.</p>
            <select class="form-control" id="action" name="action">
                <c:forEach items="${actions}" var="action" >
                    <option value="${action.id}">${action.name}</option>
                </c:forEach>
            </select><br />
            <label class="form-control" for="resourceType">Subject Resource:</label>
            <p>Select the resource that when an action is preformed on it will trigger the notification.</p>
            <select class="form-control" id="resourceType" name="resourceType">
                <c:forEach items="${resourceTypes}" var="resourceType" >
                    <option value="${resourceType.id}">${resourceType.name}</option>
                </c:forEach>
            </select><br />
            <label class="form-control" for="subjectStateType">Subject Resource State:</label>
            <p>Select the state the resource must be in to trigger the notification. Multiple states can be selected by holding down the control key while selecting the names.</p>
            <select class="form-control" id="subjectStateType" name="subjectStateType" multiple="1">
                <c:forEach items="${subjectStateTypes}" var="subjectStateType" >
                    <option value="${subjectStateType.id}">${subjectStateType.name}</option>
                </c:forEach>
                <%--
               <option value="0">No State</option>
               <option value="6">Finalized</option>
               <option value="7">Draft</option>
                --%>
            </select><br />
            <label class="form-control" for="includeCurrentUser">Include my actions</label>
            <p>Check this box if you wish to be notified when you preform an action that matches this template.</p>
            <input class="form-control" type="checkbox" name="includeCurrentUser" id="includeCurrentUser" value="true" />
            <br />
        </div>
        <button class="btn btn-primary" name="formSubmit" id="formSubmit" value="create-notificationtemplate" type="submit">Create Notification Template</button>
    </form>
</div>

